<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>新博客系统注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all" />
<!--[if IE 6]><link type="text/css" rel="stylesheet" href="css/ie6.css" media="all" /><![endif]-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/mootools.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/site.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function _change() {
	/*
	1. 获取img元素
	*/
	var imgEle = document.getElementById("imgEle");
	// 设置它的src为servlet
	imgEle.src = "<c:url value='/verifyCode.action'/>?" + new Date().getTime();
}
 function check(show){   

         /*        var url = '${pageContext.request.contextPath}/validateLogin.action';
                var params = $('#userform').serialize();
                  $('#warn').html("<img src='image/ajax/wait.gif'/>"); 

                jQuery.post(url, params, callbackFun); */
              var username1=$('#username').val();
              var password1=$('#password').val();
              var repassword1=$('#repassword').val();
              var nickname1=$('#nickname').val();
              var question1=$('#question').val();
              var answer1=$('#answer').val();
              var verifyCode1=$('#verifyCode').val();
              var flag=0;
              if(show=='#warnp'){flag=1;}
              if(show=='#warnr'){flag=2;}
              if(show=='#warnn'){flag=3;}
              if(show=='#warnq'){flag=4;}
              if(show=='#warna'){flag=5;}
              if(show=='#warnv'){flag=6;}
              
$.ajax({
            
		type:'post',
		url:'${pageContext.request.contextPath}/validateRegister.action',
		//数据格式是json串，商品信息
		/* data:$('#userform').serialize(), */
		dataType:"html",
        data:{username:username1,
              password:password1,
              repassword:repassword1,
              nickname:nickname1,
              question:question1,
              answer:answer1,
              verifyCode:verifyCode1, 
              flag:flag}, 
		success:function (result) {  
                $(show).html(result);    
            }  
	});
            }

           /*  function callbackFun(data){

                $(show).html(data+111);

            } */
</script>
</head>
<body>
<div id="wrapper">
  <div id="container">
    <div id="scene"> <img src="${pageContext.request.contextPath}/images/scene.jpg" alt="" />
      <h1>博客网站系统</br>
                          欢迎您！${empty sessionScope.username ? "当前尚未登录":sessionScope.username} <br/>
      		<font size="5">${empty sessionScope.idiograph ? "":sessionScope.idiograph}</font>
      		</h1>
      <div id="scale_area">
        <div id="scale_knob">&raquo; Font Size &laquo;</div>
      </div>
      <div id="menu">
        <div class="holder"> <a href="${pageContext.request.contextPath}/showAllArticle.action">博客首页</a> </div>
        <div class="holder"> <a href="${pageContext.request.contextPath}/register.jsp">新博客注册</a> </div>
        <div class="holder"> <a href="${pageContext.request.contextPath}/login.jsp">博客登录</a> </div>
        <div class="holder"> <a href="${pageContext.request.contextPath}/logout1.action">退出</a> </div>        
      </div>
    </div>
    <div id="content">
      <div id="col_left">
        <div class="post">
          <div class="meta"></div>
          <div class="comments"><div class="comment"></div>
            <h2>新博客注册</h2>
            <form class="h" action="${pageContext.request.contextPath}/zhuCe.action" method="post">
              <div>
                <label>帐号:<font color="red" size=3><span  id="warnu"></span></font></label>
                <input type="text" name="username"id="username" onblur="check('#warnu')"/>
              </div>
              <div>
                <label>密码:<font color="red" size=3><span  id="warnp"></span></font></label>
               <input type="password" name="password"id="password" onblur="check('#warnp')"/>
              </div>
			   <div>
                <label>确认密码:<font color="red" size=3><span  id="warnr"></span></font></label>
                <input type="password" name="repassword"id="repassword" onblur="check('#warnr')"/>
              </div>
			   <div>
                <label>昵称:<font color="red" size=3><span  id="warnn"></span></font></label>
                <input type="text" name="nickname"id="nickname" onblur="check('#warnn')"/>
              </div>
			   <div>
                <label>密码保护问题:<font color="red" size=3><span  id="warnq"></span></font></label>
                <input type="text" name="question" id="question"onblur="check('#warnq')"/>
              </div>
			   <div>
                <label>密码保护的答案:<font color="red" size=3><span  id="warna"></span></font></label>
                <input type="text" name="answer" id="answer"onblur="check('#warna')"/>
              </div>
               <div>   
		         <label>验证码：<font color="red" size=3><span  id="warnv"></span></font></label>
		         <input type="text" id="verifyCode" name="verifyCode" onblur="check('#warnv')"/>
				 <img src="<c:url value='/verifyCode.action'/>" id="imgEle"/>
				 <a href="javascript:_change()">换一张</a>
		       </div>
              <div>
                <label></label>
                <div class="clear"> </div>
              </div>
              <div class="button_wrapper">
                <input name="zhuce" type="submit" class="button" id="zhuce"value="注册" />
              </div>
            </form>
          </div>
        </div>
      </div>
      <div id="col_right">
        <div id="search_box">
          <form action="" method="post">
            <div>
              <input type="text" name="search" />
            </div>
            <div class="button_wrapper">
              <input type="submit" value="Search" class="button" />
            </div>
            <div class="clear"> </div>
          </form>
        </div>
        <div id="sidebar">
          <h2>页面导航</h2>
          <ul>
            <li><a href="${pageContext.request.contextPath}/showAllArticle.action">博客首页</a></li>
            <li><a href="${pageContext.request.contextPath}/register.jsp">新博客注册</a></li>
            <li><a href="${pageContext.request.contextPath}/login.jsp">博客登录</a></li>
          </ul>
        </div>
      </div>
      <div class="clear"> </div>
    </div>
    <div id="footer">
      <div class="clear"> </div>
      <hr />
      <p class="credit">博客网站系统</p>
    </div>
  </div>
</div>
</body>
</html>
